package com.example.conf;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 用来解决跨域问题的配置类
 */
@Configuration
public class FrontConfiguration implements WebMvcConfigurer {
    public void addCorsMappings(CorsRegistry registry){
        registry.addMapping("/**") //决定支持跨域的类或者接口
                .allowedOrigins("*") //决定跨域的来源
                .allowedHeaders("*")
                .allowedMethods("GET","POST","HEAD","PUT","DELETE","OPTIONS"); //决定跨域请求的方式
    }

}
